/**
 * English Area Unit Tests
 * Tests convert and toUnit for each Unit Type
 */

package cmsc495.mach2.test.unit.english;

import cmsc495.mach2.unit.english.EnglishAreaUnit;
import junit.framework.TestCase;

/**
 * @author Michael Swann
 */

public class EnglishAreaUnitValidation extends TestCase {

	// Amount of Error Allowed
	private static final double				DELTA				= 0.01;

	private static final double				SQUAREINCHES_VALUE	= 4014489600.0;
	private static final double				SQUAREFEET_VALUE	= 27878400.0;
	private static final double				SQUAREYARDS_VALUE	= 3097600.0;
	private static final double				ACRES_VALUE			= 640.0;
	private static final double				SQUAREMILES_VALUE	= 1.0;
	private static final double				SQUAREMETERS_VALUE	= 2589988.11;

	private static final double				values[]			= { SQUAREINCHES_VALUE, SQUAREFEET_VALUE, SQUAREYARDS_VALUE, ACRES_VALUE, SQUAREMILES_VALUE, SQUAREMETERS_VALUE };
	private static final EnglishAreaUnit[]	englishAreaUnits	= EnglishAreaUnit.values();																							;

	public EnglishAreaUnitValidation() {
	}

	@Override
	protected void setUp() throws Exception {
		super.setUp();
	}

	/**
	 * Test method for
	 * {@link mach2convert.englishunit.EnglishAreaUnit#convert(double, mach2convert.englishunit.EnglishAreaUnit)}
	 * .
	 */
	public final void testConvert() {
		for (int i = 0; i < englishAreaUnits.length; i++) {
			for (int j = 0; j < englishAreaUnits.length; j++) {
				double result = englishAreaUnits[i].convert(values[j], englishAreaUnits[j]);
				System.out.println("ASSERT: " + values[i] + " = " + result + " " + englishAreaUnits[i] + ".convert(" + values[j] + ", " + englishAreaUnits[j] + "))");
				assertEquals(values[i], result, DELTA);
			}
		}
	}

	/**
	 * Test method for
	 * {@link mach2convert.englishunit.EnglishAreaUnit#toSquareInches(double)}.
	 */
	public final void testToSquareInches() {
		for (int i = 0; i < englishAreaUnits.length; i++) {
			double result = englishAreaUnits[i].toSquareInches(values[i]);
			System.out.println("ASSERT: " + SQUAREINCHES_VALUE + " = " + result + " " + englishAreaUnits[i] + ".toSquareInches(" + values[i] + ") ");
			assertEquals(SQUAREINCHES_VALUE, result, DELTA);
		}
	}

	/**
	 * Test method for
	 * {@link mach2convert.englishunit.EnglishAreaUnit#toSquareFeet(double)}.
	 */
	public final void testToSquareFeet() {
		for (int i = 0; i < englishAreaUnits.length; i++) {
			double result = englishAreaUnits[i].toSquareFeet(values[i]);
			System.out.println("ASSERT: " + SQUAREFEET_VALUE + " = " + result + " " + englishAreaUnits[i] + ".toSquareFeet(" + values[i] + ") ");
			assertEquals(SQUAREFEET_VALUE, result, DELTA);
		}
	}

	/**
	 * Test method for
	 * {@link mach2convert.englishunit.EnglishAreaUnit#toSquareYards(double)}.
	 */
	public final void testToSquareYards() {
		for (int i = 0; i < englishAreaUnits.length; i++) {
			double result = englishAreaUnits[i].toSquareYards(values[i]);
			System.out.println("ASSERT: " + SQUAREYARDS_VALUE + " = " + result + " " + englishAreaUnits[i] + ".toSquareYards(" + values[i] + ") ");
			assertEquals(SQUAREYARDS_VALUE, result, DELTA);
		}
	}

	/**
	 * Test method for
	 * {@link mach2convert.englishunit.EnglishAreaUnit#toAcres(double)}.
	 */
	public final void testToAcres() {
		for (int i = 0; i < englishAreaUnits.length; i++) {
			double result = englishAreaUnits[i].toAcres(values[i]);
			System.out.println("ASSERT: " + ACRES_VALUE + " = " + result + " " + englishAreaUnits[i] + ".toAcres(" + values[i] + ") ");
			assertEquals(ACRES_VALUE, result, DELTA);
		}
	}

	/**
	 * Test method for
	 * {@link mach2convert.englishunit.EnglishAreaUnit#toSquareMiles(double)}.
	 */
	public final void testToSquareMiles() {
		for (int i = 0; i < englishAreaUnits.length; i++) {
			double result = englishAreaUnits[i].toSquareMiles(values[i]);
			System.out.println("ASSERT: " + SQUAREMILES_VALUE + " = " + result + " " + englishAreaUnits[i] + ".toSquareMiles(" + values[i] + ") ");
			assertEquals(SQUAREMILES_VALUE, result, DELTA);
		}
	}

	/**
	 * Test method for
	 * {@link mach2convert.englishunit.EnglishAreaUnit#toSquareMeters(double)}.
	 */
	public final void testToSquareMeters() {
		for (int i = 0; i < englishAreaUnits.length; i++) {
			double result = englishAreaUnits[i].toSquareMeters(values[i]);
			System.out.println("ASSERT: " + SQUAREMETERS_VALUE + " = " + result + " " + englishAreaUnits[i] + ".toSquareMeters(" + values[i] + ") ");
			assertEquals(SQUAREMETERS_VALUE, result, DELTA);
		}
	}

}